//
//  CZComposeButton.swift
//  WeiBo
//
//  Created by Apple on 16/9/7.
//  Copyright © 2016年 KY. All rights reserved.
//

import UIKit
//  封装撰写菜单按钮
class CZComposeButton: UIButton {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //  去掉高亮, 重新高亮属性方法
    override var isHighlighted: Bool {
        get {
            return false
        } set {
        
        }
        
    }
    
    private func setupUI() {
        titleLabel?.font = UIFont.systemFont(ofSize: 14)
        setTitleColor(UIColor.gray, for: .normal)
        //  文字居中
        titleLabel?.textAlignment = .center
        //  图片显示
        imageView?.contentMode = .center
    
    }
    
    
    //  调整子控件的布局
    override func layoutSubviews() {
        super.layoutSubviews()
        
        imageView?.width = width
        imageView?.height = width
        imageView?.y = 0
        imageView?.x = 0
        
        
        titleLabel?.height = height - width
        titleLabel?.width = width
        titleLabel?.y = width
        titleLabel?.x = 0
        
        
        
    }
    

}
